package com.tucue.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.tucue.adapter.GenericAdapter;
import com.tucue.dao.ActivityMapper;
import com.tucue.dao.MerchantsOrderMapper;
import com.tucue.dao.NewsMapper;
import com.tucue.model.Activity;
import com.tucue.model.MerchantsOrder;
import com.tucue.model.News;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by tutu on 15/1/21.
 */
public class QueryBaseController extends BaseController {
    public List<News> getParkNews() {

        try {
            this.getSqlSession();
            NewsMapper mapper = sqlSession.getMapper(NewsMapper.class);
            List<News> newsList = mapper.selectAll();
            return newsList;
        } catch (Exception ex) {
            ex.printStackTrace();
            return  null;
        }
        finally {
            this.closeSqlSession();
        }
    }



    public  List<Activity>  getParkActivity ()
    {
        try
        {
            this.getSqlSession();
            ActivityMapper mapper=sqlSession.getMapper(ActivityMapper.class);
            List<Activity> activityList = mapper.selectAll(1);
            return activityList;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return null;
        }
        finally {
            this.closeSqlSession();
        }

    }



    public List<MerchantsOrder>   parkQueryApply()
    {

        try
        {
            this.getSqlSession();
            MerchantsOrderMapper mapper=sqlSession.getMapper(MerchantsOrderMapper.class);
            List<MerchantsOrder> merchantsOrdersList = mapper.selectAll();

            return merchantsOrdersList;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return null;
        }
        finally {
            this.closeSqlSession();
        }
    }


}
